<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>    
<%@ include  file="../init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>提交订单</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>
	<body>
	<%@ include  file="../header_1.jsp"%>
	
	   
	<div class="container">
    <div class="row">
        <div class="col-md-1">
             <%@ include file="../menu.jsp" %>
        </div>
        <div class="col-md-11">

            <!-- page-header -->
            <div class="page-header">
                <div class="page-comm">
                    <div class="mt">
                        <h3>创建订单</h3>
                    </div>
                    <div class="mc">
                        <!--
                        <a href="/shop-pc/manage/address/select">
                            <p class="address-title">请选择收货人地址: <span style="float:right"><i class="fa fa-angle-right"></i></span></p>
                        </a>
                        <div class="order-address">
                            <div class="clearfix">
                                <div class="pull-left">默认地址:邱宇航 , 广东省深圳市市辖区宝安区 西乡街道 f518时尚创意园 14栋401</div>
                                <div class="pull-right"><i class="fa fa-mobile"></i>18720989381</div>
                            </div>
                        </div>
                        -->
                    </div>
                </div>
            </div>
            <!-- /.page-header -->

            <div class="page-content">
                <div class="page-comm">
              <div class="order-pay" style="width:100%;background:#FFF;margin:10px 0;">
                        <div class="pay-panel" style="padding:10px;text-align:left">
                            <p style="border-left:4px solid #FF3333;padding-left:20px;color:#666;font-size:16px;margin-bottom:5px;">
                                您绑定的手机号码 : ${phone}</p>
                        </div>
                    </div>
                    <div class="order-pay" style="width:100%;background:#FFF;margin:10px 0;">
                        <div class="pay-panel" style="padding:10px;text-align:left">
                            <div style="border-left:4px solid #FF3333;padding-left:20px;color:#666;font-size:16px;margin-bottom:5px;" class="clearfix">
                                <c:if test="${memberAddress!=null }">
                                    <div class="pull-left"> 收货地址 :${memberAddress.name } , ${memberAddress.address },${memberAddress.telephone }</div>
                                    <div class="pull-right">
                                      <a href="${path}/manage/myCenter/myAddress" target="_blank" style="font-weight:bold;color:#005ea7">更多地址</a>
                                    </div>
                                </c:if>
                                <c:if test="${memberAddress==null }">
                                  <div class="pull-left"> <a href="${path}/manage/myCenter/myAddress" style="font-weight:bold;color:#005ea7">新增收货地址</a></div>
                                </c:if>
                               
                            </div>
                        </div>
                    </div>

                    <div class="order-pay" style="width:100%;background:#FFF;margin:10px 0;">
                        <div class="pay-panel" style="padding:10px;text-align:left">
                            <p style="border-left:4px solid #FF3333;padding-left:20px;color:#666;font-size:16px;margin-bottom:5px;">
                                支付方式 : 在线付款</p>
                        </div>
                    </div>

                    <div class="order-delivery" style="width:100%;background:#FFF;margin:10px 0;">
                        <div class="delivery-panel" style="padding:10px;text-align:left">
                            <p style="border-left:4px solid #FF3333;padding-left:20px;color:#666;font-size:16px;margin-bottom:5px;">
                                配送方式 : 送货上门</p>
                        </div>
                    </div>
                   
                    <!--订单信息开始-->
                    <div class="order-content">
                        <table class="table">
                            <tbody>
                            <tr>
                                <th>商品</th>
                                <th width="60">数量</th>
                                <th width="100" class="text-right">单价</th>
                            </tr> 
                           <c:forEach items="${vo.cartItem}" var="goods"> 
	                            <tr>
	                                <td>
	                                    <img src="${goods.goods.picurl}" style="width:50px;height:50px;">
	                                      ${goods.goods.name}
	                                </td>
	                                <td>
	                                    <span class="info-num">x${goods.amount}</span> 
	                                </td>
	                                <td class="text-right">
	                                    <span class="info-gold"><em class="price">￥${goods.price}</em></span>
	                                </td>
	                            </tr>    
                           </c:forEach>
                            </tbody>
                        </table>
                    </div>
                    <!--订单信息结束-->

                    <!--订单核算开始-->
                    <div class="ordre-summary" style="background:#FFF;text-align:left;padding:10px">
                        <p style="border-bottom:1px solid #ddd;height:30px;line-height:30px;">
                            <span style="color:#666;font-size:14px;">商品金额</span>
                            <span class="info-num" style="float:right;"><em class="price">￥${vo.total}</em></span>
                        </p>
                        <p style="height:30px;line-height:30px;">
                            <span style="color:#666;font-size:14px;">运费</span>
                            <span class="info-gold" style="float:right;">0.00</span>
                        </p>
                    </div>
                    <!--订单核算结束-->

                    <div class="clearfix">
                        <!--
                        <div class="pull-left" >
                            <span style="color:#666;margin-left:10px;">实付款：149.91元</span>
                        </div>
                        -->
                        <div class="pull-right">
                            <span style="margin-right:10px;">应付总额：<em class="price">￥${vo.total}</em></span>
                            <a class="btn btn-danger " onclick="submitOrder()" id="submitBtn">提交订单</a>
                        </div>
                    </div>

                </div>
            </div>
            <!-- /.page-content -->
    <input type="hidden" value="${memberAddress.id}" id="addressid">
    <input type="hidden" value="${phone}" id="telephone">

        </div>
    </div>
</div>
	
	 <%@ include  file="../footer.jsp"%>
	</body>
	
	<script type="text/javascript">
	
	 function submitOrder(){
		 var addressId=$("#addressid").val();
		 if(addressId==''){
			 
			 common.alert({ 
					content:"请新增收货地址",
					ok : function() {   
						window.location.href="${path}/manage/myCenter/myAddress";
					}
				})
				
				
				
			return null;
		 }
		 $.ajax({
	 	        url: "${path}/manage/commodityOrder/create",
	 	        type: "post",
	 	        data:{
	 	        	"marketid":"${marketId}",
	 	        	"addressid":addressId,
	 	        	"couponRecordId":0,
	 	        	"paymode":"1"
	 	        },
	 	        success: function(data) {
	 	        	if(data.code == "000"){
	 	        		window.location.href="${path}/manage/order/pay/"+data.result;
	 	        	}else if(data.code == "300"){
	 	        		common.alert({
						    dialog: true,
							content:data.msg
						})
	 	        	}
	 	        }
	 	    });	
	 }
	
	</script>
	
</html>
